package manager

import (
	"gitee.com/g-qs/gin-vue-admin/server/global"
	"gitee.com/g-qs/gin-vue-admin/server/model/manager"
	"time"
)

type TargetPlanService struct {
}

// SaveTargetPlan 保存目标计划
// Author [g-qs](https://github.com/g-qs)
func (targetPlanService *TargetPlanService) SaveTargetPlan(targetPlan *manager.TargetPlan) (err error) {
	targetPlan.UpdatedAt = time.Now()
	err = global.GVA_DB.Where("hm_id = ?", targetPlan.HmId).Updates(&targetPlan).Error
	return
}

// GetTargetPlan 获取目标计划
// Author [g-qs](https://github.com/g-qs)
func (targetPlanService *TargetPlanService) GetTargetPlan(HmId uint) (targetPlan manager.TargetPlan, err error) {
	err = global.GVA_DB.Where("hm_id = ?", HmId).First(&targetPlan).Error
	return
}

func (targetPlanService *TargetPlanService) ChangeTargetPlan(targetPlan *manager.TargetPlan) (err error) {
	targetPlan.UpdatedAt = time.Now()
	err = global.GVA_DB.Where("hm_id = ?", targetPlan.HmId).Updates(&targetPlan).Error
	return
}
